package chapter04.s08enum;

public class TestEnum {
    public static void main(String[] args) {
        // 定义枚举变量
        EColor red = EColor.RED;
        printColor(red);

        // valueOf ：Returns the enum constant of this type with the specified name.
        EColor blue = EColor.valueOf("BLUE");
        printColor(blue);

        // values 遍历枚举
        for (EColor color : EColor.values()) {
            printColor(color);
        }

    }

    // 枚举作为参数
    private static void printColor(EColor color) {
        // switch 中的枚举
        switch (color) {
            case RED:
                System.out.println("红色");
                break;
            case GREEN:
                System.out.println("绿色");
                break;
            case BLUE:
                System.out.println("蓝色");
                break;
        }
    }
}
